package com.fgw.admin.web;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.fgw.admin.dto.ResultInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.*;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;

import com.fgw.admin.entity.ProgressBase;
import com.fgw.admin.service.IProgressBaseService;

/**
 * 项目进度基础情况 前端控制器
 *
 * @author system
 * @date 2020-11-20 00:36:00
 */
@Controller
@RequestMapping("/progressBase")
public class ProgressBaseController {
    @Resource
    private IProgressBaseService iProgressBaseService;

    @RequestMapping("/*")
    public void toHtml(){

    }

    @RequestMapping("/listData")
    @RequiresPermissions("progressBase:view")
    public @ResponseBody
    ResultInfo<List<ProgressBase>> listData(ProgressBase progressBase,@RequestParam(defaultValue="1") Integer page,@RequestParam(defaultValue="10") Integer limit){
        EntityWrapper<ProgressBase> wrapper = new EntityWrapper<>(progressBase);
        Page<ProgressBase> pageObj = iProgressBaseService.selectPage(new Page<>(page,limit), wrapper);
        return new ResultInfo<>(pageObj.getRecords(), pageObj.getTotal());
    }

    @RequestMapping("/add")
    @RequiresPermissions("progressBase:add")
    public @ResponseBody
    ResultInfo<Boolean> add(ProgressBase progressBase){
        boolean b = iProgressBaseService.insert(progressBase);
        return new ResultInfo<>(b);
    }

    @RequestMapping("/delBatch")
    @RequiresPermissions("progressBase:del")
    public @ResponseBody
    ResultInfo<Boolean> delBatch(Integer[] idArr){
        boolean b = iProgressBaseService.deleteBatchIds(Arrays.asList(idArr));
        return new ResultInfo<>(b);
    }

    @RequestMapping("/edit")
    @RequiresPermissions("progressBase:edit")
    public @ResponseBody
    ResultInfo<Boolean> edit(ProgressBase progressBase){
        boolean b = iProgressBaseService.updateById(progressBase);
        return new ResultInfo<>(b);
    }

}
